Skip to content

fix(cli): v1 config rejecting endpoints without explicit port#1576

Merged
benalleng merged 2 commits into
payjoin:masterfrom
va-an:fix/v1-endpoint-implicit-port
May 28, 2026
Merged

fix(cli): v1 config rejecting endpoints without explicit port#1576
benalleng merged 2 commits into
payjoin:masterfrom
va-an:fix/v1-endpoint-implicit-port

Conversation

@va-an
Copy link
Copy Markdown
Contributor

@va-an va-an commented May 24, 2026

-> % payjoin-cli --bip78 --port 3000 --pj-endpoint https://example.com/ receive 50000

Error: If --port is 0, --pj-endpoint may not have a port

Two problems here:

  • --port is 3000, not 0.
  • The command should succeed, because this is a valid reverse-proxy setup - nginx terminating TLS on 443 and forwarding to payjoin-cli on 3000.
Pull Request Checklist

Please confirm the following before requesting review:

State the port check's single invariant directly: `--port 0`
(let the OS pick) is incompatible with a `--pj-endpoint` URL
that pins a specific port.
@coveralls
Copy link
Copy Markdown
Collaborator

coveralls commented May 24, 2026

Coverage Report for CI Build 26398782191

Coverage increased (+0.05%) to 85.192%

Details

  • Coverage increased (+0.05%) from the base build.
  • Patch coverage: 29 of 29 lines across 1 file are fully covered (100%).
  • No coverage regressions found.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 13729
Covered Lines: 11696
Line Coverage: 85.19%
Coverage Strength: 394.49 hits per line

💛 - Coveralls

Copy link
Copy Markdown
Contributor

@caarloshenriq caarloshenriq left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tACK

The condition rewrite from pj_endpoint.port().is_none() != (v1.port == 0) to v1.port == 0 && v1.pj_endpoint.port().is_some() reads much more clearly and the tests confirm each case: random port rejected only when the endpoint has an explicit port, and allowed when it does not

Comment on lines +408 to +410
fn accepts_explicit_port_with_different_explicit_endpoint_port() {
Config::new(&cli("3000", "https://example.com:443/")).unwrap();
}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the expected behavior here? Should the config override the existing endpoint port?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Expected behavior - the test should not fail, because this is a valid configuratin combination.

On the precedence between the config file and CLI args - I checked locally that CLI args have higher priority. If port and/or pj_endpoint are set in both the config file and CLI args, the CLI values are used.

I don't think we should rewrite the port inside pj_endpoint from port, because they can legitimately difffer. For example, when the receiver runs behind an nginx reverse proxy, port is the local bind port while pj_endpoint's port is the public one that ends up in the BIP21 URL.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh right ok

Copy link
Copy Markdown
Collaborator

@benalleng benalleng left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK d030068

@benalleng benalleng merged commit 81c8db8 into payjoin:master May 28, 2026
14 checks passed
@va-an va-an deleted the fix/v1-endpoint-implicit-port branch May 28, 2026 16:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants